package com.ly.houses.api;

import com.alibaba.druid.util.StringUtils;
import com.ly.houses.model.Result;
import com.ly.houses.model.ResultUtil;
import com.ly.houses.service.LoginService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/login")
public class LoginApi {
    @Resource
    private LoginService loginService;

    @GetMapping("/getOpenId")
    public Result getOpenId(HttpSession session, String code) {
        if (StringUtils.isEmpty(code)) {
            return ResultUtil.error(7777, "缺少请求参数");
        }
        return loginService.getOpenId(session, code);
    }
}
